<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var buttonObj;
        window.onload=function (){
            buttonObj=document.getElementById("button");
            buttonObj.onclick=function (){
                alert("baby");
            }
        }
        function cancel(){
            buttonObj.onclick=null;
        }
    </script>
</head>
<body>
<input type="button" value="确定" id="button">
<br>
<input type="button" value="取消" onclick="cancel()">
</body>
</html>